home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / guppyClass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  7.9 KB  |  249 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include "gl.h"
  22. #include "geom.h"
  23. #include "selectors.h"
  24. #include "class.h"
  25. #include "classIds.h"
  26. #include "mbox.h"
  27. #include "individual.h"
  28. #include "behavior.h"
  29. #include "doers.h"
  30.  
  31. #include "colors.h"
  32.  
  33. extern class indivClass;
  34. model guppyBody, guppyTail;
  35.  
  36. extern char *changeSpeed(), *changeHead(), *changeAzimuth();
  37.  
  38. fcnTable guppyTable[] = {
  39.     NEWSPEED,        changeSpeed,
  40.     NEWHEADING,        changeHead,
  41.     NEWAZIMUTH,        changeAzimuth,
  42.     EOTABLE,
  43. };
  44.  
  45. class guppyClass = {
  46.     &indivClass,
  47.     guppyTable,
  48.     sizeof(individual),
  49.     GUPPY,
  50. };
  51.  
  52. individual guppyTemplate = {
  53.             /*   inst        */
  54.     &guppyClass,    /* myClass pointer    */
  55.     NULL,        /* classFunctions     */
  56.     0,            /* nFunctions        */
  57.             /*   mailbox        */
  58.     NULL,        /* subscribers          */
  59.     NULL,        /* subscribedTo         */
  60.             /*   individual        */
  61.     {0,0,0},        /* position        */
  62.     {0,0,0},        /* lastPosition        */
  63.     {1,0,0},        /* delta        */
  64.     {1,1,1},        /* velocity        */
  65.     {1,1,1},        /* avelocity        */
  66.     {3,4,0},        /* acceleration        */
  67.     30.0,        /* speed        */
  68.     {40,50,10},        /* heading        */
  69.     {0,0,0},        /* rotation        */
  70.     {0,0,0},        /* influence        */
  71.     1.0,        /* scale                */
  72.     &guppyBody,        /* model        */
  73.     ORDER,        /* flags        */
  74.     NULL,        /* curVars              */
  75. };
  76.  
  77. point guppyBodyPoints[] = {
  78.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  79.     {  600,  000,  000, },
  80.     {  000, -100,  000, },
  81.     {  000,  100,  000, },
  82.     {  150,  000, -320, },
  83.     {  590,  000, -150, },
  84.     {  510,  000, -250, },
  85.     {  300,  000, -320, },
  86. };
  87.         
  88. point guppyEyePoints[] = {
  89.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  90.     {  -10,  000,    0, },
  91.     {   10,  000,   30, },
  92.     {   10,  000,   60, },
  93.     {  -10,  000,   80, },
  94.     {  -30,  000,  100, },
  95.     {  -70,  000,  100, },
  96.     {  -80,  000,   90, },
  97.     { -100,  000,   60, },
  98.     { -100,  000,   30, },
  99.     {  -90,  000,    0, },
  100.     {  -40,  000,  -10, },
  101. };
  102.         
  103. point guppyIrisPoints[] = {
  104.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  105.     {  -10,  000,    0, },
  106.     {   10,  000,   30, },
  107.     {   10,  000,   60, },
  108.     {  -10,  000,   80, },
  109.     {  -40,  000,   90, },
  110.     {  -70,  000,   70, },
  111.     {  -80,  000,   40, },
  112.     {  -70,  000,   10, },
  113.     {  -40,  000,    0, },
  114. };
  115.  
  116. point guppyTailPoints[] = {
  117.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  118.     {    0,  000,    0, },
  119.     { -300,  000,  600, },
  120.     { -300,  000, -300, },
  121. };
  122.         /* null terminated polys, double null at end */
  123. long guppyBodyVertices[] = {
  124.     1,5,6,7,4,2,0,
  125.     1,3,4,7,6,5,0,
  126.     1,2,3,0,
  127.     2,4,3,0,
  128.     0,
  129. };
  130. long guppyLEyeVertices[] = {
  131.     1,2,3,4,5,6,7,8,9,10,11,0,
  132.     0,
  133. };
  134. long guppyLIrisVertices[] = {
  135.     1,2,3,4,5,6,7,8,9,0,
  136.     0,
  137. };
  138. long guppyREyeVertices[] = {
  139.     11,10,9,8,7,6,5,4,3,2,1,0,
  140.     0,
  141. };
  142. long guppyRIrisVertices[] = {
  143.     9,8,7,6,5,4,3,2,1,0,
  144.     0,
  145. };
  146. long guppyTailVertices[] = {
  147.     1,2,3,0,
  148.     1,3,2,0,
  149.     0,
  150. };
  151.  
  152. model guppyTail = {
  153.     NULL,            /* next model segment          */
  154.     NULL,            /* child model segments        */
  155.     0,                /* geometry compiled yet?      */
  156.     0,                /* compiled geometry object Id */
  157.     guppyTailPoints,        /* point dictionary            */
  158.     guppyTailVertices,        /* polygon descriptions        */
  159.     { -100,0,-100},        /* centroid                    */
  160.     GUPPYTAIL_COLOR,        /* color                       */
  161.     GUPPYTAIL_TEXTURE,        /* texture                     */
  162.     TRUE,            /* outlined                    */
  163.     { 0,0,0},            /* rotation                    */
  164.     { 100,0,-200},        /* translation                 */
  165.     { 1.0,1.0,1.0},        /* scale                       */
  166.     5,                /* declasse               */
  167. };
  168.         
  169. model guppyLIris = {
  170.     NULL,            /* next model segment          */
  171.     NULL,            /* child model segments        */
  172.     0,                /* geometry compiled yet?      */
  173.     0,                /* compiled geometry object Id */
  174.     guppyIrisPoints,        /* point dictionary            */
  175.     guppyLIrisVertices,        /* polygon descriptions        */
  176.     { -40,0,45},        /* centroid                    */
  177.     GUPPYIRIS_COLOR,        /* color                       */
  178.     GUPPYIRIS_TEXTURE,        /* texture                     */
  179.     FALSE,            /* outlined                    */
  180.     { 0,0,0},            /* rotation                    */
  181.     { 0,0,0},            /* translation                 */
  182.     { 1.0,1.0,1.0},        /* scale                       */
  183.     25,                /* declasse               */
  184. };
  185. model guppyLEye = {
  186.     NULL,            /* next model segment          */
  187.     &guppyLIris,        /* child model segments        */
  188.     0,                /* geometry compiled yet?      */
  189.     0,                /* compiled geometry object Id */
  190.     guppyEyePoints,        /* point dictionary            */
  191.     guppyLEyeVertices,         /* polygon descriptions        */
  192.     { -45,0,45},        /* centroid                    */
  193.     GUPPYEYE_COLOR,        /* color                       */
  194.     GUPPYEYE_TEXTURE,        /* texture                     */
  195.     FALSE,            /* outlined                    */
  196.     { 0,0,0},            /* rotation                    */
  197.     { 500,-25,-120},        /* translation                 */
  198.     { 1.0,1.0,1.0},        /* scale                       */
  199.     30,                /* declasse               */
  200. };
  201. model guppyRIris = {
  202.     NULL,            /* next model segment          */
  203.     NULL,            /* child model segments        */
  204.     0,                /* geometry compiled yet?      */
  205.     0,                /* compiled geometry object Id */
  206.     guppyIrisPoints,        /* point dictionary            */
  207.     guppyRIrisVertices,        /* polygon descriptions        */
  208.     { -40,0,45},        /* centroid                    */
  209.     GUPPYIRIS_COLOR,        /* color                       */
  210.     GUPPYIRIS_TEXTURE,        /* texture                     */
  211.     FALSE,            /* outlined                    */
  212.     { 0,0,0},            /* rotation                    */
  213.     { 0,0,0},            /* translation                 */
  214.     { 1.0,1.0,1.0},        /* scale                       */
  215.     25,                /* declasse               */
  216. };
  217. model guppyREye = {
  218.     &guppyLEye,            /* next model segment          */
  219.     &guppyRIris,        /* child model segments        */
  220.     0,                /* geometry compiled yet?      */
  221.     0,                /* compiled geometry object Id */
  222.     guppyEyePoints,        /* point dictionary            */
  223.     guppyREyeVertices,         /* polygon descriptions        */
  224.     { -45,0,45},        /* centroid                    */
  225.     GUPPYEYE_COLOR,        /* color                       */
  226.     GUPPYEYE_TEXTURE,        /* texture                     */
  227.     FALSE,            /* outlined                    */
  228.     { 0,0,0},            /* rotation                    */
  229.     { 500,25,-120},        /* translation                 */
  230.     { 1.0,1.0,1.0},        /* scale                       */
  231.     30,                /* declasse               */
  232. };
  233. model guppyBody = {
  234.     &guppyTail,            /* next model segment          */
  235.     &guppyREye,            /* child model segments        */
  236.     0,                /* geometry compiled yet?      */
  237.     0,                /* compiled geometry object Id */
  238.     guppyBodyPoints,        /* point dictionary            */
  239.     guppyBodyVertices,         /* polygon descriptions        */
  240.     { 300,0,-200},        /* centroid                    */
  241.     GUPPYBODY_COLOR,        /* color                       */
  242.     GUPPYBODY_TEXTURE,        /* texture                     */
  243.     TRUE,            /* outlined                    */
  244.     { 0,0,0},            /* rotation                    */
  245.     { 0,0,0},            /* translation                 */
  246.     { 1.0,1.0,1.0},        /* scale                       */
  247.     0,                /* declasse               */
  248. };
  249.